package com.hmall.trade;

import com.hmall.api.config.DefaultFeigenConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

/**
 * ClassName: TradeApplication
 * Package:
 * Description
 *  交易微服务，包含订单相关功能，启动类
 * @Author xw
 * @Create 2023/12/9 10:41
 */

@MapperScan("com.hmall.trade.mapper")
@SpringBootApplication
//@EnableFeignClients  // 启用  OpenFeign
@EnableFeignClients(basePackages = "com.hmall.api.client",defaultConfiguration = DefaultFeigenConfig.class)
public class TradeApplication {
    public static void main(String[] args) {
        SpringApplication.run(TradeApplication.class, args);
    }

    @Bean
    public MessageConverter messageConverter(){
        // 1.定义消息转换器
        Jackson2JsonMessageConverter jackson2JsonMessageConverter = new Jackson2JsonMessageConverter();
        // 2.配置自动创建消息id，用于识别不同消息，也可以在业务中基于ID判断是否是重复消息
        jackson2JsonMessageConverter.setCreateMessageIds(true);
        return jackson2JsonMessageConverter;
    }

}
